﻿using System;
using System.Collections;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Threading;
using BLL;

namespace MZ.server
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class CardHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            var code = context.Request.QueryString["code"];
            var cardID = context.Request.QueryString["cid"];
            switch (code)
            {
                case "delete":
                    context.Response.ContentType = "text/plain";
                    var r = CardBLL.DeleteCard(context.User.Identity.Name, cardID);
                    context.Response.Write(r.ToString());
                    break;
                case "edit":
                    context.Response.ContentType = "application/json";
                    //TODO:编辑
                    var card = CardBLL.GetMyCard(context.User.Identity.Name, cardID);
                    var json = BLL.Util.Json.ConvertToJson(card);
                    context.Response.Write(json);
                    break;
                default:
                    break;
            }
            
            
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
